--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
libs/able/able/permissions.py 2.0.0 (cf698d96) Text, 2.02 KB
T8b949e"""Before executing, all :class:`BluetoothDispatcher <able.BluetoothDispatcher>` methods that requires Bluetooth adapter
(`start_scan`, `connect_by_device_address`, `enable_notifications`, `adapter` property ...),
are asking the user to:
The list of requested runtime permissions varies depending on the level of the target Android API level:
* target API level <=30: ACCESS_FINE_LOCATION - to obtain BLE scan results
* target API level >= 31:
* BLUETOOTH_CONNECT - to enable adapter and to connect to devices
* BLUETOOTH_SCAN - to start the scan
* ACCESS_FINE_LOCATION - to detect beacons during the scan
* BLUETOOTH_ADVERTISE - to be able to advertise to nearby Bluetooth devices
Requested permissions list can be changed with the `BluetoothDispatcher.runtime_permissions` parameter.
"""
Tff7b72from T7ee787jnius Tff7b72import Te6edf3autoclass
Te6edf3SDK_INT Tff7b72= Tffa657intTb4b4b4(Te6edf3autoclassTb4b4b4(Ta5d6ff"Ta5d6ffandroid.os.Build$VERSIONTa5d6ff"Tb4b4b4)Tff7b72.Td2a8ffSDK_INTTb4b4b4)
Tff7b72class T56d364PermissionTb4b4b4:
T8b949e"""
String constants values for BLE-related permissions.
https://developer.android.com/reference/android/Manifest.permission
"""
Te6edf3ACCESS_BACKGROUND_LOCATION Tff7b72= Ta5d6ff"Ta5d6ffandroid.permission.ACCESS_BACKGROUND_LOCATIONTa5d6ff"
Te6edf3ACCESS_FINE_LOCATION Tff7b72= Ta5d6ff"Ta5d6ffandroid.permission.ACCESS_FINE_LOCATIONTa5d6ff"
Te6edf3BLUETOOTH_ADVERTISE Tff7b72= Ta5d6ff"Ta5d6ffandroid.permission.BLUETOOTH_ADVERTISETa5d6ff"
Te6edf3BLUETOOTH_CONNECT Tff7b72= Ta5d6ff"Ta5d6ffandroid.permission.BLUETOOTH_CONNECTTa5d6ff"
Te6edf3BLUETOOTH_SCAN Tff7b72= Ta5d6ff"Ta5d6ffandroid.permission.BLUETOOTH_SCANTa5d6ff"
Tff7b72if Te6edf3SDK_INT Tff7b72>Tff7b72= T79c0ff31Tb4b4b4:
T8b949e# API level 31 (Android 12) introduces new permissions
Te6edf3DEFAULT_RUNTIME_PERMISSIONS Tff7b72= Tb4b4b4[
Te6edf3PermissionTff7b72.Td2a8ffBLUETOOTH_ADVERTISETb4b4b4,
Te6edf3PermissionTff7b72.Td2a8ffBLUETOOTH_CONNECTTb4b4b4,
Te6edf3PermissionTff7b72.Td2a8ffBLUETOOTH_SCANTb4b4b4,
T8b949e# ACCESS_FINE_LOCATION is not mandatory for scan,
T8b949e# but required to discover beacons
Te6edf3PermissionTff7b72.Td2a8ffACCESS_FINE_LOCATIONTb4b4b4,
Tb4b4b4]
Tff7b72elseTb4b4b4:
T8b949e# For API levels 29-30,
T8b949e# ACCESS_FINE_LOCATION permission is needed to obtain BLE scan results
Te6edf3DEFAULT_RUNTIME_PERMISSIONS Tff7b72= Tb4b4b4[
Te6edf3PermissionTff7b72.Td2a8ffACCESS_FINE_LOCATIONTb4b4b4,
Tb4b4b4]
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────